<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>宇成建筑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../statics/css/font.css">
    <link rel="stylesheet" href="../statics/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="../statics/css/xadmin.css">
    <link rel="stylesheet" href="../statics/css/style.css">
    <!--    <style>th{min-width: unset !important;}</style>-->
</head>
<body class='labelAuto'>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="welcome.html">首页</a>
            <a href="javascript:;">审批</a>
            <a href="javascript:;">审批</a>
            <a><cite>考勤</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right:10px"
       onclick="window.history.go(-1)" title="后退">
        <i class="iconfontBlod" style="line-height:30px">&#xe74f;</i>
    </a>
</div>
<div class="layui-fluid attendance">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body search">
                    <form action="" class="layui-form livingList">
                        <div class="layui-form-item">
<!--                            <div class="layui-inline">-->
<!--                                <label class="layui-form-label">项目</label>-->
<!--                                <div class="layui-input-block">-->
<!--                                    <select name="" id="project">-->
<!--                                        <option value="">-</option>-->
<!--                                    </select>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                            <div class="layui-inline">-->
<!--                                <button class="layui-btn search" type="button" id='search'>-->
<!--                                    <i class="iconfont layui-icon">&#xe615;</i>-->
<!--                                </button>-->
<!--                            </div>-->
                        </div>
                    </form>
                </div>
                <div class="layui-card-body tableCardBody">
                    <table class="layui-table" id="lists" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../statics/plugins/layui/layui.js" charset="utf-8"></script>
<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
<script type="text/javascript" src="../statics/plugins/X-admin/xadmin.js"></script>
<script type="text/javascript" src="../statics/js/public.js?v=1129"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', "table", "laydate"], function () {
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var approvalId = getQueryString('approvalId');
        var month = getQueryString('month');
        var projectId = getQueryString('projectId');
        var professionId = getQueryString('professionId');

        var days = (new Date(month.substr(0,4), month.substr(5,2), 0)).getDate();
        var column = [ //表头
            {field: '', title: '编号', type: 'numbers',width:60,fixed:'left'},
            {field: 'name', title: '姓名',width:80,fixed:'left'},
            {field: 'jobNumber', title: '工号',width:90,fixed:'left'},
            {field: 'professionName', title: '工种',width:90,fixed:'left'},
            {field: 'projectName', title: '现属项目',width:180,fixed:'left'},
            {
                field: 'status', title: '状态',width:60,fixed:'left', templet(d) {
                    return d.status == 1 ? "在岗" : d.status == 2 ? "待岗" : d.status == 3 ? "请假" : d.status == 4 ? "离职" : "";
                }
            },
            {field: 1, title: 1, width: 60, templet: function (d) {return columnCallBack(d,1);}},
            {field: 2, title: 2, width: 60, templet: function (d) {return columnCallBack(d,2);}},
            {field: 3, title: 3, width: 60, templet: function (d) {return columnCallBack(d,3);}},
            {field: 4, title: 4, width: 60, templet: function (d) {return columnCallBack(d,4);}},
            {field: 5, title: 5, width: 60, templet: function (d) {return columnCallBack(d,5);}},
            {field: 6, title: 6, width: 60, templet: function (d) {return columnCallBack(d,6);}},
            {field: 7, title: 7, width: 60, templet: function (d) {return columnCallBack(d,7);}},
            {field: 8, title: 8, width: 60, templet: function (d) {return columnCallBack(d,8);}},
            {field: 9, title: 9, width: 60, templet: function (d) {return columnCallBack(d,9);}},
            {field: 10, title: 10, width: 60, templet: function (d) {return columnCallBack(d,10);}},
            {field: 11, title: 11, width: 60, templet: function (d) {return columnCallBack(d,11);}},
            {field: 12, title: 12, width: 60, templet: function (d) {return columnCallBack(d,12);}},
            {field: 13, title: 13, width: 60, templet: function (d) {return columnCallBack(d,13);}},
            {field: 14, title: 14, width: 60, templet: function (d) {return columnCallBack(d,14);}},
            {field: 15, title: 15, width: 60, templet: function (d) {return columnCallBack(d,15);}},
            {field: 16, title: 16, width: 60, templet: function (d) {return columnCallBack(d,16);}},
            {field: 17, title: 17, width: 60, templet: function (d) {return columnCallBack(d,17);}},
            {field: 18, title: 18, width: 60, templet: function (d) {return columnCallBack(d,18);}},
            {field: 19, title: 19, width: 60, templet: function (d) {return columnCallBack(d,19);}},
            {field: 20, title: 20, width: 60, templet: function (d) {return columnCallBack(d,20);}},
            {field: 21, title: 21, width: 60, templet: function (d) {return columnCallBack(d,21);}},
            {field: 22, title: 22, width: 60, templet: function (d) {return columnCallBack(d,22);}},
            {field: 23, title: 23, width: 60, templet: function (d) {return columnCallBack(d,23);}},
            {field: 24, title: 24, width: 60, templet: function (d) {return columnCallBack(d,24);}},
            {field: 25, title: 25, width: 60, templet: function (d) {return columnCallBack(d,25);}},
            {field: 26, title: 26, width: 60, templet: function (d) {return columnCallBack(d,26);}},
            {field: 27, title: 27, width: 60, templet: function (d) {return columnCallBack(d,27);}},
            {field: 28, title: 28, width: 60, templet: function (d) {return columnCallBack(d,28);}},
            {field: 29, title: 29, width: 60, templet: function (d) {return columnCallBack(d,29);}},
            {field: 30, title: 30, width: 60, templet: function (d) {return columnCallBack(d,30);}},
            {field: 31, title: 31, width: 60, templet: function (d) {return columnCallBack(d,31);}},
            {
                field: 'sum', title: '汇总', width: 70, templet: function (d) {
                    var sum = 0;
                    for (var i in d.attendance) {
                        if (d.attendance[i].projectId == projectId){
                            sum += Number(d.attendance[i].long);
                        }
                    }
                    return `<span title="" class='currProject'>${sum}</span>`;
                }
            },
        ];

        var minus = 31 - days;
        var tmpColumn = column.slice(0);
        for (var m = 0; m < minus; m++) {
            // tmpColumn.pop();
            tmpColumn.splice(-2,1);
        }
        // var minus = 31-days;
        // for (var m=0 ; m<minus;m++){
        //     column.pop();
        // }
        tmpColumn.push({
            field: 'status', title: '审核类型',width:'6%',fixed:'right', templet: function (d) {
                if (d.status === 1) {
                    return '待审核';
                } else if (d.status === 2) {
                    return '审核中';
                } else if (d.status === 3) {
                    return '已通过';
                } else if (d.status === 4) {
                    return '被驳回';
                } else{
                    return '-';
                }
            }
        });
        var lists = table.render({
            elem: '#lists', //绑定DOM元素
            id: 'lists', //table的id
            title: '人员列表',
            height: 'full-150',
            contentType: "application/json; charset=utf-8",
            url: url + '/approval/approval/approvalDataAttendance', //数据接口地址
            request: {
                pageName: 'page', //页码的参数名称，默认：page
                limitName: 'length' //每页数据量的参数名，默认：limit
            },
            method: 'POST',
            parseData: function (res) {
                return {
                    "code": res.code, //解析接口状态
                    "data": res.data.data,
                    "msg": res.msg,
                };
            },
            where: {
                approvalId: approvalId,
                projectId: projectId,
                professionId: Number(professionId),
                month:month,
                token: getToken()
            },
            toolbar: '#toolbar',
            defaultToolbar: ['filter','exports'],
            page: false, //开启分页
            limit: 10, //默认每页记录条数
            limits: [10, 20, 50], //每页记录条数可选数量
            cols: [
                tmpColumn
            ],
            response: {
                statusName: 'code', //数据状态的字段名称，默认：code
                statusCode: 100000, //成功的状态码，默认：0
                msgName: 'msg', //状态信息的字段名称，默认：msg
                countName: 'count', //数据总数的字段名称，默认：count
                dataName: 'data' //数据列表的字段名称，默认：data
            }
        });

        table.on('tool(test)',function(data){

        })

        function columnCallBack(d,i){
            return `<span title="${d.attendance[i].projectName}">${d.attendance[i].long}</span>`
        }
    });
</script>

</html>